//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2022 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

import Foundation
import SotoCore

extension LexRuntimeService {
    // MARK: Enums

    public enum ConfirmationStatus: String, CustomStringConvertible, Codable, _SotoSendable {
        case confirmed = "Confirmed"
        case denied = "Denied"
        case none = "None"
        public var description: String { return self.rawValue }
    }

    public enum ContentType: String, CustomStringConvertible, Codable, _SotoSendable {
        case applicationVndAmazonawsCardGeneric = "application/vnd.amazonaws.card.generic"
        public var description: String { return self.rawValue }
    }

    public enum DialogActionType: String, CustomStringConvertible, Codable, _SotoSendable {
        case close = "Close"
        case confirmIntent = "ConfirmIntent"
        case delegate = "Delegate"
        case elicitIntent = "ElicitIntent"
        case elicitSlot = "ElicitSlot"
        public var description: String { return self.rawValue }
    }

    public enum DialogState: String, CustomStringConvertible, Codable, _SotoSendable {
        case confirmIntent = "ConfirmIntent"
        case elicitIntent = "ElicitIntent"
        case elicitSlot = "ElicitSlot"
        case failed = "Failed"
        case fulfilled = "Fulfilled"
        case readyForFulfillment = "ReadyForFulfillment"
        public var description: String { return self.rawValue }
    }

    public enum FulfillmentState: String, CustomStringConvertible, Codable, _SotoSendable {
        case failed = "Failed"
        case fulfilled = "Fulfilled"
        case readyForFulfillment = "ReadyForFulfillment"
        public var description: String { return self.rawValue }
    }

    public enum MessageFormatType: String, CustomStringConvertible, Codable, _SotoSendable {
        case composite = "Composite"
        case customPayload = "CustomPayload"
        case plainText = "PlainText"
        case ssml = "SSML"
        public var description: String { return self.rawValue }
    }

    // MARK: Shapes

    public struct ActiveContext: AWSEncodableShape & AWSDecodableShape {
        /// The name of the context.
        public let name: String
        /// State variables for the current context. You can use these values as default values for slots in subsequent events.
        public let parameters: [String: String]
        /// The length of time or number of turns that a context remains active.
        public let timeToLive: ActiveContextTimeToLive

        public init(name: String, parameters: [String: String], timeToLive: ActiveContextTimeToLive) {
            self.name = name
            self.parameters = parameters
            self.timeToLive = timeToLive
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 100)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^([A-Za-z]_?)+$")
            try self.parameters.forEach {
                try validate($0.key, name: "parameters.key", parent: name, max: 100)
                try validate($0.key, name: "parameters.key", parent: name, min: 1)
                try validate($0.value, name: "parameters[\"\($0.key)\"]", parent: name, max: 1024)
                try validate($0.value, name: "parameters[\"\($0.key)\"]", parent: name, min: 1)
            }
            try self.validate(self.parameters, name: "parameters", parent: name, max: 10)
            try self.timeToLive.validate(name: "\(name).timeToLive")
        }

        private enum CodingKeys: String, CodingKey {
            case name
            case parameters
            case timeToLive
        }
    }

    public struct ActiveContextTimeToLive: AWSEncodableShape & AWSDecodableShape {
        /// The number of seconds that the context should be active after it is first sent in a PostContent or PostText response. You can set the value between 5 and 86,400 seconds (24 hours).
        public let timeToLiveInSeconds: Int?
        /// The number of conversation turns that the context should be active. A conversation turn is one PostContent or PostText request and the corresponding response from Amazon Lex.
        public let turnsToLive: Int?

        public init(timeToLiveInSeconds: Int? = nil, turnsToLive: Int? = nil) {
            self.timeToLiveInSeconds = timeToLiveInSeconds
            self.turnsToLive = turnsToLive
        }

        public func validate(name: String) throws {
            try self.validate(self.timeToLiveInSeconds, name: "timeToLiveInSeconds", parent: name, max: 86400)
            try self.validate(self.timeToLiveInSeconds, name: "timeToLiveInSeconds", parent: name, min: 5)
            try self.validate(self.turnsToLive, name: "turnsToLive", parent: name, max: 20)
            try self.validate(self.turnsToLive, name: "turnsToLive", parent: name, min: 1)
        }

        private enum CodingKeys: String, CodingKey {
            case timeToLiveInSeconds
            case turnsToLive
        }
    }

    public struct Button: AWSDecodableShape {
        /// Text that is visible to the user on the button.
        public let text: String
        /// The value sent to Amazon Lex when a user chooses the button. For example, consider button text "NYC." When the user chooses the button, the value sent can be "New York City."
        public let value: String

        public init(text: String, value: String) {
            self.text = text
            self.value = value
        }

        private enum CodingKeys: String, CodingKey {
            case text
            case value
        }
    }

    public struct DeleteSessionRequest: AWSEncodableShape {
        public static var _encoding = [
            AWSMemberEncoding(label: "botAlias", location: .uri("botAlias")),
            AWSMemberEncoding(label: "botName", location: .uri("botName")),
            AWSMemberEncoding(label: "userId", location: .uri("userId"))
        ]

        /// The alias in use for the bot that contains the session data.
        public let botAlias: String
        /// The name of the bot that contains the session data.
        public let botName: String
        /// The identifier of the user associated with the session data.
        public let userId: String

        public init(botAlias: String, botName: String, userId: String) {
            self.botAlias = botAlias
            self.botName = botName
            self.userId = userId
        }

        public func validate(name: String) throws {
            try self.validate(self.userId, name: "userId", parent: name, max: 100)
            try self.validate(self.userId, name: "userId", parent: name, min: 2)
            try self.validate(self.userId, name: "userId", parent: name, pattern: "[0-9a-zA-Z._:-]+")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct DeleteSessionResponse: AWSDecodableShape {
        /// The alias in use for the bot associated with the session data.
        public let botAlias: String?
        /// The name of the bot associated with the session data.
        public let botName: String?
        /// The unique identifier for the session.
        public let sessionId: String?
        /// The ID of the client application user.
        public let userId: String?

        public init(botAlias: String? = nil, botName: String? = nil, sessionId: String? = nil, userId: String? = nil) {
            self.botAlias = botAlias
            self.botName = botName
            self.sessionId = sessionId
            self.userId = userId
        }

        private enum CodingKeys: String, CodingKey {
            case botAlias
            case botName
            case sessionId
            case userId
        }
    }

    public struct DialogAction: AWSEncodableShape & AWSDecodableShape {
        /// The fulfillment state of the intent. The possible values are:    Failed - The Lambda function associated with the intent failed to fulfill the intent.    Fulfilled - The intent has fulfilled by the Lambda function associated with the intent.     ReadyForFulfillment - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.
        public let fulfillmentState: FulfillmentState?
        /// The name of the intent.
        public let intentName: String?
        /// The message that should be shown to the user. If you don't specify a message, Amazon Lex will use the message configured for the intent.
        public let message: String?
        ///    PlainText - The message contains plain UTF-8 text.    CustomPayload - The message is a custom format for the client.    SSML - The message contains text formatted for voice output.    Composite - The message contains an escaped JSON object containing one or more messages. For more information, see Message Groups.
        public let messageFormat: MessageFormatType?
        /// Map of the slots that have been gathered and their values.
        public let slots: [String: String]?
        /// The name of the slot that should be elicited from the user.
        public let slotToElicit: String?
        /// The next action that the bot should take in its interaction with the user. The possible values are:    ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"    Close - Indicates that the there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.    Delegate - The next action is determined by Amazon Lex.    ElicitIntent - The next action is to determine the intent that the user wants to fulfill.    ElicitSlot - The next action is to elicit a slot value from the user.
        public let type: DialogActionType

        public init(fulfillmentState: FulfillmentState? = nil, intentName: String? = nil, message: String? = nil, messageFormat: MessageFormatType? = nil, slots: [String: String]? = nil, slotToElicit: String? = nil, type: DialogActionType) {
            self.fulfillmentState = fulfillmentState
            self.intentName = intentName
            self.message = message
            self.messageFormat = messageFormat
            self.slots = slots
            self.slotToElicit = slotToElicit
            self.type = type
        }

        public func validate(name: String) throws {
            try self.validate(self.message, name: "message", parent: name, max: 1024)
            try self.validate(self.message, name: "message", parent: name, min: 1)
        }

        private enum CodingKeys: String, CodingKey {
            case fulfillmentState
            case intentName
            case message
            case messageFormat
            case slots
            case slotToElicit
            case type
        }
    }

    public struct GenericAttachment: AWSDecodableShape {
        /// The URL of an attachment to the response card.
        public let attachmentLinkUrl: String?
        /// The list of options to show to the user.
        public let buttons: [Button]?
        /// The URL of an image that is displayed to the user.
        public let imageUrl: String?
        /// The subtitle shown below the title.
        public let subTitle: String?
        /// The title of the option.
        public let title: String?

        public init(attachmentLinkUrl: String? = nil, buttons: [Button]? = nil, imageUrl: String? = nil, subTitle: String? = nil, title: String? = nil) {
            self.attachmentLinkUrl = attachmentLinkUrl
            self.buttons = buttons
            self.imageUrl = imageUrl
            self.subTitle = subTitle
            self.title = title
        }

        private enum CodingKeys: String, CodingKey {
            case attachmentLinkUrl
            case buttons
            case imageUrl
            case subTitle
            case title
        }
    }

    public struct GetSessionRequest: AWSEncodableShape {
        public static var _encoding = [
            AWSMemberEncoding(label: "botAlias", location: .uri("botAlias")),
            AWSMemberEncoding(label: "botName", location: .uri("botName")),
            AWSMemberEncoding(label: "checkpointLabelFilter", location: .querystring("checkpointLabelFilter")),
            AWSMemberEncoding(label: "userId", location: .uri("userId"))
        ]

        /// The alias in use for the bot that contains the session data.
        public let botAlias: String
        /// The name of the bot that contains the session data.
        public let botName: String
        /// A string used to filter the intents returned in the recentIntentSummaryView structure.  When you specify a filter, only intents with their checkpointLabel field set to that string are returned.
        public let checkpointLabelFilter: String?
        /// The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot.
        public let userId: String

        public init(botAlias: String, botName: String, checkpointLabelFilter: String? = nil, userId: String) {
            self.botAlias = botAlias
            self.botName = botName
            self.checkpointLabelFilter = checkpointLabelFilter
            self.userId = userId
        }

        public func validate(name: String) throws {
            try self.validate(self.checkpointLabelFilter, name: "checkpointLabelFilter", parent: name, max: 255)
            try self.validate(self.checkpointLabelFilter, name: "checkpointLabelFilter", parent: name, min: 1)
            try self.validate(self.checkpointLabelFilter, name: "checkpointLabelFilter", parent: name, pattern: "[a-zA-Z0-9-]+")
            try self.validate(self.userId, name: "userId", parent: name, max: 100)
            try self.validate(self.userId, name: "userId", parent: name, min: 2)
            try self.validate(self.userId, name: "userId", parent: name, pattern: "[0-9a-zA-Z._:-]+")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct GetSessionResponse: AWSDecodableShape {
        /// A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the PostContent, PostText, or PutSession operation. You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.
        public let activeContexts: [ActiveContext]?
        /// Describes the current state of the bot.
        public let dialogAction: DialogAction?
        /// An array of information about the intents used in the session. The array can contain a maximum of three summaries. If more than three intents are used in the session, the recentIntentSummaryView operation contains information about the last three intents used. If you set the checkpointLabelFilter parameter in the request, the array contains only the intents with the specified label.
        public let recentIntentSummaryView: [IntentSummary]?
        /// Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.
        public let sessionAttributes: [String: String]?
        /// A unique identifier for the session.
        public let sessionId: String?

        public init(activeContexts: [ActiveContext]? = nil, dialogAction: DialogAction? = nil, recentIntentSummaryView: [IntentSummary]? = nil, sessionAttributes: [String: String]? = nil, sessionId: String? = nil) {
            self.activeContexts = activeContexts
            self.dialogAction = dialogAction
            self.recentIntentSummaryView = recentIntentSummaryView
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts
            case dialogAction
            case recentIntentSummaryView
            case sessionAttributes
            case sessionId
        }
    }

    public struct IntentConfidence: AWSDecodableShape {
        /// A score that indicates how confident Amazon Lex is that an intent satisfies the user's intent. Ranges between 0.00 and 1.00. Higher scores indicate higher confidence.
        public let score: Double?

        public init(score: Double? = nil) {
            self.score = score
        }

        private enum CodingKeys: String, CodingKey {
            case score
        }
    }

    public struct IntentSummary: AWSEncodableShape & AWSDecodableShape {
        /// A user-defined label that identifies a particular intent. You can use this label to return to a previous intent.  Use the checkpointLabelFilter parameter of the GetSessionRequest operation to filter the intents returned by the operation to those with only the specified label.
        public let checkpointLabel: String?
        /// The status of the intent after the user responds to the confirmation prompt. If the user confirms the intent, Amazon Lex sets this field to Confirmed. If the user denies the intent, Amazon Lex sets this value to Denied. The possible values are:    Confirmed - The user has responded "Yes" to the confirmation prompt, confirming that the intent is complete and that it is ready to be fulfilled.    Denied - The user has responded "No" to the confirmation prompt.    None - The user has never been prompted for confirmation; or, the user was prompted but did not confirm or deny the prompt.
        public let confirmationStatus: ConfirmationStatus?
        /// The next action that the bot should take in its interaction with the user. The possible values are:    ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"    Close - Indicates that the there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.    ElicitIntent - The next action is to determine the intent that the user wants to fulfill.    ElicitSlot - The next action is to elicit a slot value from the user.
        public let dialogActionType: DialogActionType
        /// The fulfillment state of the intent. The possible values are:    Failed - The Lambda function associated with the intent failed to fulfill the intent.    Fulfilled - The intent has fulfilled by the Lambda function associated with the intent.     ReadyForFulfillment - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.
        public let fulfillmentState: FulfillmentState?
        /// The name of the intent.
        public let intentName: String?
        /// Map of the slots that have been gathered and their values.
        public let slots: [String: String]?
        /// The next slot to elicit from the user. If there is not slot to elicit, the field is blank.
        public let slotToElicit: String?

        public init(checkpointLabel: String? = nil, confirmationStatus: ConfirmationStatus? = nil, dialogActionType: DialogActionType, fulfillmentState: FulfillmentState? = nil, intentName: String? = nil, slots: [String: String]? = nil, slotToElicit: String? = nil) {
            self.checkpointLabel = checkpointLabel
            self.confirmationStatus = confirmationStatus
            self.dialogActionType = dialogActionType
            self.fulfillmentState = fulfillmentState
            self.intentName = intentName
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        public func validate(name: String) throws {
            try self.validate(self.checkpointLabel, name: "checkpointLabel", parent: name, max: 255)
            try self.validate(self.checkpointLabel, name: "checkpointLabel", parent: name, min: 1)
            try self.validate(self.checkpointLabel, name: "checkpointLabel", parent: name, pattern: "[a-zA-Z0-9-]+")
        }

        private enum CodingKeys: String, CodingKey {
            case checkpointLabel
            case confirmationStatus
            case dialogActionType
            case fulfillmentState
            case intentName
            case slots
            case slotToElicit
        }
    }

    public struct PostContentRequest: AWSEncodableShape & AWSShapeWithPayload {
        /// The key for the payload
        public static let _payloadPath: String = "inputStream"
        public static let _options: AWSShapeOptions = [.rawPayload, .allowStreaming, .allowChunkedStreaming]
        public static var _encoding = [
            AWSMemberEncoding(label: "accept", location: .header("Accept")),
            AWSMemberEncoding(label: "activeContexts", location: .header("x-amz-lex-active-contexts")),
            AWSMemberEncoding(label: "botAlias", location: .uri("botAlias")),
            AWSMemberEncoding(label: "botName", location: .uri("botName")),
            AWSMemberEncoding(label: "contentType", location: .header("Content-Type")),
            AWSMemberEncoding(label: "requestAttributes", location: .header("x-amz-lex-request-attributes")),
            AWSMemberEncoding(label: "sessionAttributes", location: .header("x-amz-lex-session-attributes")),
            AWSMemberEncoding(label: "userId", location: .uri("userId"))
        ]

        ///  You pass this value as the Accept HTTP header.  The message Amazon Lex returns in the response can be either text or speech based on the Accept HTTP header value in the request.    If the value is text/plain; charset=utf-8, Amazon Lex returns text in the response.    If the value begins with audio/, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech (using the configuration you specified in the Accept header). For example, if you specify audio/mpeg as the value, Amazon Lex returns speech in the MPEG format.   If the value is audio/pcm, the speech returned is audio/pcm in 16-bit, little endian format.    The following are the accepted values:   audio/mpeg   audio/ogg   audio/pcm   text/plain; charset=utf-8   audio/* (defaults to mpeg)
        public let accept: String?
        /// A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request, If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
        public let activeContexts: String?
        /// Alias of the Amazon Lex bot.
        public let botAlias: String
        /// Name of the Amazon Lex bot.
        public let botName: String
        ///  You pass this value as the Content-Type HTTP header.  Indicates the audio format or text. The header value must start with one of the following prefixes:    PCM format, audio data must be in little-endian byte order.   audio/l16; rate=16000; channels=1   audio/x-l16; sample-rate=16000; channel-count=1   audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false      Opus format   audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=256000; frame-size-milliseconds=4     Text format   text/plain; charset=utf-8
        public let contentType: String
        ///  User input in PCM or Opus audio format or text format as described in the Content-Type HTTP header.  You can stream audio data to Amazon Lex or you can create a local buffer that captures all of the audio data before sending. In general, you get better performance if you stream audio data rather than buffering the data locally.
        public let inputStream: AWSPayload
        /// You pass this value as the x-amz-lex-request-attributes HTTP header. Request-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the requestAttributes and sessionAttributes headers is limited to 12 KB. The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex:. For more information, see Setting Request Attributes.
        public let requestAttributes: String?
        /// You pass this value as the x-amz-lex-session-attributes HTTP header. Application-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the sessionAttributes and requestAttributes headers is limited to 12 KB. For more information, see Setting Session Attributes.
        public let sessionAttributes: String?
        /// The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the userID field. To decide the user ID to use for your application, consider the following factors.   The userID field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.   If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.   If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.   A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.
        public let userId: String

        public init(accept: String? = nil, activeContexts: String? = nil, botAlias: String, botName: String, contentType: String, inputStream: AWSPayload, requestAttributes: String? = nil, sessionAttributes: String? = nil, userId: String) {
            self.accept = accept
            self.activeContexts = activeContexts
            self.botAlias = botAlias
            self.botName = botName
            self.contentType = contentType
            self.inputStream = inputStream
            self.requestAttributes = requestAttributes
            self.sessionAttributes = sessionAttributes
            self.userId = userId
        }

        public func validate(name: String) throws {
            try self.validate(self.userId, name: "userId", parent: name, max: 100)
            try self.validate(self.userId, name: "userId", parent: name, min: 2)
            try self.validate(self.userId, name: "userId", parent: name, pattern: "[0-9a-zA-Z._:-]+")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct PostContentResponse: AWSDecodableShape & AWSShapeWithPayload {
        /// The key for the payload
        public static let _payloadPath: String = "audioStream"
        public static let _options: AWSShapeOptions = [.rawPayload, .allowStreaming]
        public static var _encoding = [
            AWSMemberEncoding(label: "activeContexts", location: .header("x-amz-lex-active-contexts")),
            AWSMemberEncoding(label: "alternativeIntents", location: .header("x-amz-lex-alternative-intents")),
            AWSMemberEncoding(label: "botVersion", location: .header("x-amz-lex-bot-version")),
            AWSMemberEncoding(label: "contentType", location: .header("Content-Type")),
            AWSMemberEncoding(label: "dialogState", location: .header("x-amz-lex-dialog-state")),
            AWSMemberEncoding(label: "encodedInputTranscript", location: .header("x-amz-lex-encoded-input-transcript")),
            AWSMemberEncoding(label: "encodedMessage", location: .header("x-amz-lex-encoded-message")),
            AWSMemberEncoding(label: "inputTranscript", location: .header("x-amz-lex-input-transcript")),
            AWSMemberEncoding(label: "intentName", location: .header("x-amz-lex-intent-name")),
            AWSMemberEncoding(label: "message", location: .header("x-amz-lex-message")),
            AWSMemberEncoding(label: "messageFormat", location: .header("x-amz-lex-message-format")),
            AWSMemberEncoding(label: "nluIntentConfidence", location: .header("x-amz-lex-nlu-intent-confidence")),
            AWSMemberEncoding(label: "sentimentResponse", location: .header("x-amz-lex-sentiment")),
            AWSMemberEncoding(label: "sessionAttributes", location: .header("x-amz-lex-session-attributes")),
            AWSMemberEncoding(label: "sessionId", location: .header("x-amz-lex-session-id")),
            AWSMemberEncoding(label: "slots", location: .header("x-amz-lex-slots")),
            AWSMemberEncoding(label: "slotToElicit", location: .header("x-amz-lex-slot-to-elicit"))
        ]

        /// A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the PostContent, PostText, or PutSession operation. You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.
        public let activeContexts: String?
        /// One to four alternative intents that may be applicable to the user's intent. Each alternative includes a score that indicates how confident Amazon Lex is that the intent matches the user's intent. The intents are sorted by the confidence score.
        public let alternativeIntents: String?
        /// The prompt (or statement) to convey to the user. This is based on the bot configuration and context. For example, if Amazon Lex did not understand the user intent, it sends the clarificationPrompt configured for the bot. If the intent requires confirmation before taking the fulfillment action, it sends the confirmationPrompt. Another example: Suppose that the Lambda function successfully fulfilled the intent, and sent a message to convey to the user. Then Amazon Lex sends that message in the response.
        public let audioStream: AWSPayload?
        /// The version of the bot that responded to the conversation. You can use this information to help determine if one version of a bot is performing better than another version.
        public let botVersion: String?
        /// Content type as specified in the Accept HTTP header in the request.
        public let contentType: String?
        /// Identifies the current state of the user interaction. Amazon Lex returns one of the following values as dialogState. The client can optionally use this information to customize the user interface.     ElicitIntent - Amazon Lex wants to elicit the user's intent. Consider the following examples:  For example, a user might utter an intent ("I want to order a pizza"). If Amazon Lex cannot infer the user intent from this utterance, it will return this dialog state.     ConfirmIntent - Amazon Lex is expecting a "yes" or "no" response.  For example, Amazon Lex wants user confirmation before fulfilling an intent. Instead of a simple "yes" or "no" response, a user might respond with additional information. For example, "yes, but make it a thick crust pizza" or "no, I want to order a drink." Amazon Lex can process such additional information (in these examples, update the crust type slot or change the intent from OrderPizza to OrderDrink).     ElicitSlot - Amazon Lex is expecting the value of a slot for the current intent.  For example, suppose that in the response Amazon Lex sends this message: "What size pizza would you like?". A user might reply with the slot value (e.g., "medium"). The user might also provide additional information in the response (e.g., "medium thick crust pizza"). Amazon Lex can process such additional information appropriately.     Fulfilled - Conveys that the Lambda function has successfully fulfilled the intent.     ReadyForFulfillment - Conveys that the client has to fulfill the request.     Failed - Conveys that the conversation with the user failed.  This can happen for various reasons, including that the user does not provide an appropriate response to prompts from the service (you can configure how many times Amazon Lex can prompt a user for specific information), or if the Lambda function fails to fulfill the intent.
        public let dialogState: DialogState?
        /// The text used to process the request. If the input was an audio stream, the encodedInputTranscript field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values. You can use this information to determine if Amazon Lex is correctly processing the audio that you send. The encodedInputTranscript field is base-64 encoded. You must  decode the field before you can use the value.
        public let encodedInputTranscript: String?
        /// The message to convey to the user. The message can come from the bot's configuration or from a Lambda function. If the intent is not configured with a Lambda function, or if the Lambda function returned Delegate as the dialogAction.type in its response, Amazon Lex decides on the next course of action and selects an appropriate message from the bot's configuration based on the current interaction context. For example, if Amazon Lex isn't able to understand user input, it uses a clarification prompt message. When you create an intent you can assign messages to groups. When messages are assigned to groups Amazon Lex returns one message from each group in the response. The message field is an escaped JSON string containing the messages. For more information about the structure of the JSON string returned, see msg-prompts-formats. If the Lambda function returns a message, Amazon Lex passes it to the client in its response. The encodedMessage field is base-64 encoded. You must  decode the field before you can use the value.
        public let encodedMessage: String?
        /// The text used to process the request. You can use this field only in the de-DE, en-AU, en-GB, en-US, es-419, es-ES, es-US, fr-CA, fr-FR, and it-IT locales. In all other locales, the inputTranscript field is null. You should use the encodedInputTranscript field instead. If the input was an audio stream, the inputTranscript field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values. You can use this information to determine if Amazon Lex is correctly processing the audio that you send.
        public let inputTranscript: String?
        /// Current user intent that Amazon Lex is aware of.
        public let intentName: String?
        /// You can only use this field in the de-DE, en-AU, en-GB, en-US, es-419, es-ES, es-US, fr-CA, fr-FR, and it-IT locales. In all other locales, the message field is null. You should use the encodedMessage field instead. The message to convey to the user. The message can come from the bot's configuration or from a Lambda function. If the intent is not configured with a Lambda function, or if the Lambda function returned Delegate as the dialogAction.type in its response, Amazon Lex decides on the next course of action and selects an appropriate message from the bot's configuration based on the current interaction context. For example, if Amazon Lex isn't able to understand user input, it uses a clarification prompt message. When you create an intent you can assign messages to groups. When messages are assigned to groups Amazon Lex returns one message from each group in the response. The message field is an escaped JSON string containing the messages. For more information about the structure of the JSON string returned, see msg-prompts-formats. If the Lambda function returns a message, Amazon Lex passes it to the client in its response.
        public let message: String?
        /// The format of the response message. One of the following values:    PlainText - The message contains plain UTF-8 text.    CustomPayload - The message is a custom format for the client.    SSML - The message contains text formatted for voice output.    Composite - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.
        public let messageFormat: MessageFormatType?
        /// Provides a score that indicates how confident Amazon Lex is that the returned intent is the one that matches the user's intent. The score is between 0.0 and 1.0. The score is a relative score, not an absolute score. The score may change based on improvements to Amazon Lex.
        public let nluIntentConfidence: String?
        /// The sentiment expressed in an utterance. When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.
        public let sentimentResponse: String?
        ///  Map of key/value pairs representing the session-specific context information.
        public let sessionAttributes: String?
        /// The unique identifier for the session.
        public let sessionId: String?
        /// Map of zero or more intent slots (name/value pairs) Amazon Lex detected from the user input during the conversation. The field is base-64 encoded. Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the valueSelectionStrategy selected when the slot type was created or updated. If valueSelectionStrategy is set to ORIGINAL_VALUE, the value provided by the user is returned, if the user value is similar to the slot values. If valueSelectionStrategy is set to TOP_RESOLUTION Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a valueSelectionStrategy, the default is ORIGINAL_VALUE.
        public let slots: String?
        ///  If the dialogState value is ElicitSlot, returns the name of the slot for which Amazon Lex is eliciting a value.
        public let slotToElicit: String?

        public init(activeContexts: String? = nil, alternativeIntents: String? = nil, audioStream: AWSPayload? = nil, botVersion: String? = nil, contentType: String? = nil, dialogState: DialogState? = nil, encodedInputTranscript: String? = nil, encodedMessage: String? = nil, intentName: String? = nil, messageFormat: MessageFormatType? = nil, nluIntentConfidence: String? = nil, sentimentResponse: String? = nil, sessionAttributes: String? = nil, sessionId: String? = nil, slots: String? = nil, slotToElicit: String? = nil) {
            self.activeContexts = activeContexts
            self.alternativeIntents = alternativeIntents
            self.audioStream = audioStream
            self.botVersion = botVersion
            self.contentType = contentType
            self.dialogState = dialogState
            self.encodedInputTranscript = encodedInputTranscript
            self.encodedMessage = encodedMessage
            self.inputTranscript = nil
            self.intentName = intentName
            self.message = nil
            self.messageFormat = messageFormat
            self.nluIntentConfidence = nluIntentConfidence
            self.sentimentResponse = sentimentResponse
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        @available(*, deprecated, message: "Members inputTranscript, message have been deprecated")
        public init(activeContexts: String? = nil, alternativeIntents: String? = nil, audioStream: AWSPayload? = nil, botVersion: String? = nil, contentType: String? = nil, dialogState: DialogState? = nil, encodedInputTranscript: String? = nil, encodedMessage: String? = nil, inputTranscript: String? = nil, intentName: String? = nil, message: String? = nil, messageFormat: MessageFormatType? = nil, nluIntentConfidence: String? = nil, sentimentResponse: String? = nil, sessionAttributes: String? = nil, sessionId: String? = nil, slots: String? = nil, slotToElicit: String? = nil) {
            self.activeContexts = activeContexts
            self.alternativeIntents = alternativeIntents
            self.audioStream = audioStream
            self.botVersion = botVersion
            self.contentType = contentType
            self.dialogState = dialogState
            self.encodedInputTranscript = encodedInputTranscript
            self.encodedMessage = encodedMessage
            self.inputTranscript = inputTranscript
            self.intentName = intentName
            self.message = message
            self.messageFormat = messageFormat
            self.nluIntentConfidence = nluIntentConfidence
            self.sentimentResponse = sentimentResponse
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts = "x-amz-lex-active-contexts"
            case alternativeIntents = "x-amz-lex-alternative-intents"
            case audioStream
            case botVersion = "x-amz-lex-bot-version"
            case contentType = "Content-Type"
            case dialogState = "x-amz-lex-dialog-state"
            case encodedInputTranscript = "x-amz-lex-encoded-input-transcript"
            case encodedMessage = "x-amz-lex-encoded-message"
            case inputTranscript = "x-amz-lex-input-transcript"
            case intentName = "x-amz-lex-intent-name"
            case message = "x-amz-lex-message"
            case messageFormat = "x-amz-lex-message-format"
            case nluIntentConfidence = "x-amz-lex-nlu-intent-confidence"
            case sentimentResponse = "x-amz-lex-sentiment"
            case sessionAttributes = "x-amz-lex-session-attributes"
            case sessionId = "x-amz-lex-session-id"
            case slots = "x-amz-lex-slots"
            case slotToElicit = "x-amz-lex-slot-to-elicit"
        }
    }

    public struct PostTextRequest: AWSEncodableShape {
        public static var _encoding = [
            AWSMemberEncoding(label: "botAlias", location: .uri("botAlias")),
            AWSMemberEncoding(label: "botName", location: .uri("botName")),
            AWSMemberEncoding(label: "userId", location: .uri("userId"))
        ]

        /// A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request, If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
        public let activeContexts: [ActiveContext]?
        /// The alias of the Amazon Lex bot.
        public let botAlias: String
        /// The name of the Amazon Lex bot.
        public let botName: String
        /// The text that the user entered (Amazon Lex interprets this text).
        public let inputText: String
        /// Request-specific information passed between Amazon Lex and a client application. The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex:. For more information, see Setting Request Attributes.
        public let requestAttributes: [String: String]?
        /// Application-specific information passed between Amazon Lex and a client application. For more information, see Setting Session Attributes.
        public let sessionAttributes: [String: String]?
        /// The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the userID field. To decide the user ID to use for your application, consider the following factors.   The userID field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.   If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.   If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.   A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.
        public let userId: String

        public init(activeContexts: [ActiveContext]? = nil, botAlias: String, botName: String, inputText: String, requestAttributes: [String: String]? = nil, sessionAttributes: [String: String]? = nil, userId: String) {
            self.activeContexts = activeContexts
            self.botAlias = botAlias
            self.botName = botName
            self.inputText = inputText
            self.requestAttributes = requestAttributes
            self.sessionAttributes = sessionAttributes
            self.userId = userId
        }

        public func validate(name: String) throws {
            try self.activeContexts?.forEach {
                try $0.validate(name: "\(name).activeContexts[]")
            }
            try self.validate(self.activeContexts, name: "activeContexts", parent: name, max: 20)
            try self.validate(self.inputText, name: "inputText", parent: name, max: 1024)
            try self.validate(self.inputText, name: "inputText", parent: name, min: 1)
            try self.validate(self.userId, name: "userId", parent: name, max: 100)
            try self.validate(self.userId, name: "userId", parent: name, min: 2)
            try self.validate(self.userId, name: "userId", parent: name, pattern: "[0-9a-zA-Z._:-]+")
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts
            case inputText
            case requestAttributes
            case sessionAttributes
        }
    }

    public struct PostTextResponse: AWSDecodableShape {
        /// A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the PostContent, PostText, or PutSession operation. You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.
        public let activeContexts: [ActiveContext]?
        /// One to four alternative intents that may be applicable to the user's intent. Each alternative includes a score that indicates how confident Amazon Lex is that the intent matches the user's intent. The intents are sorted by the confidence score.
        public let alternativeIntents: [PredictedIntent]?
        /// The version of the bot that responded to the conversation. You can use this information to help determine if one version of a bot is performing better than another version.
        public let botVersion: String?
        ///  Identifies the current state of the user interaction. Amazon Lex returns one of the following values as dialogState. The client can optionally use this information to customize the user interface.     ElicitIntent - Amazon Lex wants to elicit user intent.  For example, a user might utter an intent ("I want to order a pizza"). If Amazon Lex cannot infer the user intent from this utterance, it will return this dialogState.    ConfirmIntent - Amazon Lex is expecting a "yes" or "no" response.  For example, Amazon Lex wants user confirmation before fulfilling an intent.  Instead of a simple "yes" or "no," a user might respond with additional information. For example, "yes, but make it thick crust pizza" or "no, I want to order a drink". Amazon Lex can process such additional information (in these examples, update the crust type slot value, or change intent from OrderPizza to OrderDrink).    ElicitSlot - Amazon Lex is expecting a slot value for the current intent.  For example, suppose that in the response Amazon Lex sends this message: "What size pizza would you like?". A user might reply with the slot value (e.g., "medium"). The user might also provide additional information in the response (e.g., "medium thick crust pizza"). Amazon Lex can process such additional information appropriately.     Fulfilled - Conveys that the Lambda function configured for the intent has successfully fulfilled the intent.
        ///     ReadyForFulfillment - Conveys that the client has to fulfill the intent.     Failed - Conveys that the conversation with the user failed.  This can happen for various reasons including that the user did not provide an appropriate response to prompts from the service (you can configure how many times Amazon Lex can prompt a user for specific information), or the Lambda function failed to fulfill the intent.
        public let dialogState: DialogState?
        /// The current user intent that Amazon Lex is aware of.
        public let intentName: String?
        /// The message to convey to the user. The message can come from the bot's configuration or from a Lambda function. If the intent is not configured with a Lambda function, or if the Lambda function returned Delegate as the dialogAction.type its response, Amazon Lex decides on the next course of action and selects an appropriate message from the bot's configuration based on the current interaction context. For example, if Amazon Lex isn't able to understand user input, it uses a clarification prompt message. When you create an intent you can assign messages to groups. When messages are assigned to groups Amazon Lex returns one message from each group in the response. The message field is an escaped JSON string containing the messages. For more information about the structure of the JSON string returned, see msg-prompts-formats. If the Lambda function returns a message, Amazon Lex passes it to the client in its response.
        public let message: String?
        /// The format of the response message. One of the following values:    PlainText - The message contains plain UTF-8 text.    CustomPayload - The message is a custom format defined by the Lambda function.    SSML - The message contains text formatted for voice output.    Composite - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.
        public let messageFormat: MessageFormatType?
        /// Provides a score that indicates how confident Amazon Lex is that the returned intent is the one that matches the user's intent. The score is between 0.0 and 1.0. For more information, see Confidence Scores. The score is a relative score, not an absolute score. The score may change based on improvements to Amazon Lex.
        public let nluIntentConfidence: IntentConfidence?
        /// Represents the options that the user has to respond to the current prompt. Response Card can come from the bot configuration (in the Amazon Lex console, choose the settings button next to a slot) or from a code hook (Lambda function).
        public let responseCard: ResponseCard?
        /// The sentiment expressed in and utterance. When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.
        public let sentimentResponse: SentimentResponse?
        /// A map of key-value pairs representing the session-specific context information.
        public let sessionAttributes: [String: String]?
        /// A unique identifier for the session.
        public let sessionId: String?
        ///  The intent slots that Amazon Lex detected from the user input in the conversation.  Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the valueSelectionStrategy selected when the slot type was created or updated. If valueSelectionStrategy is set to ORIGINAL_VALUE, the value provided by the user is returned, if the user value is similar to the slot values. If valueSelectionStrategy is set to TOP_RESOLUTION Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a valueSelectionStrategy, the default is ORIGINAL_VALUE.
        public let slots: [String: String]?
        /// If the dialogState value is ElicitSlot, returns the name of the slot for which Amazon Lex is eliciting a value.
        public let slotToElicit: String?

        public init(activeContexts: [ActiveContext]? = nil, alternativeIntents: [PredictedIntent]? = nil, botVersion: String? = nil, dialogState: DialogState? = nil, intentName: String? = nil, message: String? = nil, messageFormat: MessageFormatType? = nil, nluIntentConfidence: IntentConfidence? = nil, responseCard: ResponseCard? = nil, sentimentResponse: SentimentResponse? = nil, sessionAttributes: [String: String]? = nil, sessionId: String? = nil, slots: [String: String]? = nil, slotToElicit: String? = nil) {
            self.activeContexts = activeContexts
            self.alternativeIntents = alternativeIntents
            self.botVersion = botVersion
            self.dialogState = dialogState
            self.intentName = intentName
            self.message = message
            self.messageFormat = messageFormat
            self.nluIntentConfidence = nluIntentConfidence
            self.responseCard = responseCard
            self.sentimentResponse = sentimentResponse
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts
            case alternativeIntents
            case botVersion
            case dialogState
            case intentName
            case message
            case messageFormat
            case nluIntentConfidence
            case responseCard
            case sentimentResponse
            case sessionAttributes
            case sessionId
            case slots
            case slotToElicit
        }
    }

    public struct PredictedIntent: AWSDecodableShape {
        /// The name of the intent that Amazon Lex suggests satisfies the user's intent.
        public let intentName: String?
        /// Indicates how confident Amazon Lex is that an intent satisfies the user's intent.
        public let nluIntentConfidence: IntentConfidence?
        /// The slot and slot values associated with the predicted intent.
        public let slots: [String: String]?

        public init(intentName: String? = nil, nluIntentConfidence: IntentConfidence? = nil, slots: [String: String]? = nil) {
            self.intentName = intentName
            self.nluIntentConfidence = nluIntentConfidence
            self.slots = slots
        }

        private enum CodingKeys: String, CodingKey {
            case intentName
            case nluIntentConfidence
            case slots
        }
    }

    public struct PutSessionRequest: AWSEncodableShape {
        public static var _encoding = [
            AWSMemberEncoding(label: "accept", location: .header("Accept")),
            AWSMemberEncoding(label: "botAlias", location: .uri("botAlias")),
            AWSMemberEncoding(label: "botName", location: .uri("botName")),
            AWSMemberEncoding(label: "userId", location: .uri("userId"))
        ]

        /// The message that Amazon Lex returns in the response can be either text or speech based depending on the value of this field.   If the value is text/plain; charset=utf-8, Amazon Lex returns text in the response.   If the value begins with audio/, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech in the configuration that you specify. For example, if you specify audio/mpeg as the value, Amazon Lex returns speech in the MPEG format.   If the value is audio/pcm, the speech is returned as audio/pcm in 16-bit, little endian format.   The following are the accepted values:    audio/mpeg     audio/ogg     audio/pcm     audio/* (defaults to mpeg)    text/plain; charset=utf-8
        public let accept: String?
        /// A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request, If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
        public let activeContexts: [ActiveContext]?
        /// The alias in use for the bot that contains the session data.
        public let botAlias: String
        /// The name of the bot that contains the session data.
        public let botName: String
        /// Sets the next action that the bot should take to fulfill the conversation.
        public let dialogAction: DialogAction?
        /// A summary of the recent intents for the bot. You can use the intent summary view to set a checkpoint label on an intent and modify attributes of intents. You can also use it to remove or add intent summary objects to the list. An intent that you modify or add to the list must make sense for the bot. For example, the intent name must be valid for the bot. You must provide valid values for:    intentName    slot names    slotToElict    If you send the recentIntentSummaryView parameter in a PutSession request, the contents of the new summary view replaces the old summary view. For example, if a GetSession request returns three intents in the summary view and you call PutSession with one intent in the summary view, the next call to GetSession will only return one intent.
        public let recentIntentSummaryView: [IntentSummary]?
        /// Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.
        public let sessionAttributes: [String: String]?
        /// The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot.
        public let userId: String

        public init(accept: String? = nil, activeContexts: [ActiveContext]? = nil, botAlias: String, botName: String, dialogAction: DialogAction? = nil, recentIntentSummaryView: [IntentSummary]? = nil, sessionAttributes: [String: String]? = nil, userId: String) {
            self.accept = accept
            self.activeContexts = activeContexts
            self.botAlias = botAlias
            self.botName = botName
            self.dialogAction = dialogAction
            self.recentIntentSummaryView = recentIntentSummaryView
            self.sessionAttributes = sessionAttributes
            self.userId = userId
        }

        public func validate(name: String) throws {
            try self.activeContexts?.forEach {
                try $0.validate(name: "\(name).activeContexts[]")
            }
            try self.validate(self.activeContexts, name: "activeContexts", parent: name, max: 20)
            try self.dialogAction?.validate(name: "\(name).dialogAction")
            try self.recentIntentSummaryView?.forEach {
                try $0.validate(name: "\(name).recentIntentSummaryView[]")
            }
            try self.validate(self.recentIntentSummaryView, name: "recentIntentSummaryView", parent: name, max: 3)
            try self.validate(self.userId, name: "userId", parent: name, max: 100)
            try self.validate(self.userId, name: "userId", parent: name, min: 2)
            try self.validate(self.userId, name: "userId", parent: name, pattern: "[0-9a-zA-Z._:-]+")
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts
            case dialogAction
            case recentIntentSummaryView
            case sessionAttributes
        }
    }

    public struct PutSessionResponse: AWSDecodableShape & AWSShapeWithPayload {
        /// The key for the payload
        public static let _payloadPath: String = "audioStream"
        public static let _options: AWSShapeOptions = [.rawPayload, .allowStreaming]
        public static var _encoding = [
            AWSMemberEncoding(label: "activeContexts", location: .header("x-amz-lex-active-contexts")),
            AWSMemberEncoding(label: "contentType", location: .header("Content-Type")),
            AWSMemberEncoding(label: "dialogState", location: .header("x-amz-lex-dialog-state")),
            AWSMemberEncoding(label: "encodedMessage", location: .header("x-amz-lex-encoded-message")),
            AWSMemberEncoding(label: "intentName", location: .header("x-amz-lex-intent-name")),
            AWSMemberEncoding(label: "message", location: .header("x-amz-lex-message")),
            AWSMemberEncoding(label: "messageFormat", location: .header("x-amz-lex-message-format")),
            AWSMemberEncoding(label: "sessionAttributes", location: .header("x-amz-lex-session-attributes")),
            AWSMemberEncoding(label: "sessionId", location: .header("x-amz-lex-session-id")),
            AWSMemberEncoding(label: "slots", location: .header("x-amz-lex-slots")),
            AWSMemberEncoding(label: "slotToElicit", location: .header("x-amz-lex-slot-to-elicit"))
        ]

        /// A list of active contexts for the session.
        public let activeContexts: String?
        /// The audio version of the message to convey to the user.
        public let audioStream: AWSPayload?
        /// Content type as specified in the Accept HTTP header in the request.
        public let contentType: String?
        ///     ConfirmIntent - Amazon Lex is expecting a "yes" or "no" response to confirm the intent before fulfilling an intent.    ElicitIntent - Amazon Lex wants to elicit the user's intent.    ElicitSlot - Amazon Lex is expecting the value of a slot for the current intent.    Failed - Conveys that the conversation with the user has failed. This can happen for various reasons, including the user does not provide an appropriate response to prompts from the service, or if the Lambda function fails to fulfill the intent.    Fulfilled - Conveys that the Lambda function has sucessfully fulfilled the intent.    ReadyForFulfillment - Conveys that the client has to fulfill the intent.
        public let dialogState: DialogState?
        /// The next message that should be presented to the user. The encodedMessage field is base-64 encoded. You must  decode the field before you can use the value.
        public let encodedMessage: String?
        /// The name of the current intent.
        public let intentName: String?
        /// The next message that should be presented to the user. You can only use this field in the de-DE, en-AU, en-GB, en-US, es-419, es-ES, es-US, fr-CA, fr-FR, and it-IT locales. In all other locales, the message field is null. You should use the encodedMessage field instead.
        public let message: String?
        /// The format of the response message. One of the following values:    PlainText - The message contains plain UTF-8 text.    CustomPayload - The message is a custom format for the client.    SSML - The message contains text formatted for voice output.    Composite - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.
        public let messageFormat: MessageFormatType?
        /// Map of key/value pairs representing session-specific context information.
        public let sessionAttributes: String?
        /// A unique identifier for the session.
        public let sessionId: String?
        /// Map of zero or more intent slots Amazon Lex detected from the user input during the conversation. Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the valueSelectionStrategy selected when the slot type was created or updated. If valueSelectionStrategy is set to ORIGINAL_VALUE, the value provided by the user is returned, if the user value is similar to the slot values. If valueSelectionStrategy is set to TOP_RESOLUTION Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a valueSelectionStrategy the default is ORIGINAL_VALUE.
        public let slots: String?
        /// If the dialogState is ElicitSlot, returns the name of the slot for which Amazon Lex is eliciting a value.
        public let slotToElicit: String?

        public init(activeContexts: String? = nil, audioStream: AWSPayload? = nil, contentType: String? = nil, dialogState: DialogState? = nil, encodedMessage: String? = nil, intentName: String? = nil, messageFormat: MessageFormatType? = nil, sessionAttributes: String? = nil, sessionId: String? = nil, slots: String? = nil, slotToElicit: String? = nil) {
            self.activeContexts = activeContexts
            self.audioStream = audioStream
            self.contentType = contentType
            self.dialogState = dialogState
            self.encodedMessage = encodedMessage
            self.intentName = intentName
            self.message = nil
            self.messageFormat = messageFormat
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        @available(*, deprecated, message: "Members message have been deprecated")
        public init(activeContexts: String? = nil, audioStream: AWSPayload? = nil, contentType: String? = nil, dialogState: DialogState? = nil, encodedMessage: String? = nil, intentName: String? = nil, message: String? = nil, messageFormat: MessageFormatType? = nil, sessionAttributes: String? = nil, sessionId: String? = nil, slots: String? = nil, slotToElicit: String? = nil) {
            self.activeContexts = activeContexts
            self.audioStream = audioStream
            self.contentType = contentType
            self.dialogState = dialogState
            self.encodedMessage = encodedMessage
            self.intentName = intentName
            self.message = message
            self.messageFormat = messageFormat
            self.sessionAttributes = sessionAttributes
            self.sessionId = sessionId
            self.slots = slots
            self.slotToElicit = slotToElicit
        }

        private enum CodingKeys: String, CodingKey {
            case activeContexts = "x-amz-lex-active-contexts"
            case audioStream
            case contentType = "Content-Type"
            case dialogState = "x-amz-lex-dialog-state"
            case encodedMessage = "x-amz-lex-encoded-message"
            case intentName = "x-amz-lex-intent-name"
            case message = "x-amz-lex-message"
            case messageFormat = "x-amz-lex-message-format"
            case sessionAttributes = "x-amz-lex-session-attributes"
            case sessionId = "x-amz-lex-session-id"
            case slots = "x-amz-lex-slots"
            case slotToElicit = "x-amz-lex-slot-to-elicit"
        }
    }

    public struct ResponseCard: AWSDecodableShape {
        /// The content type of the response.
        public let contentType: ContentType?
        /// An array of attachment objects representing options.
        public let genericAttachments: [GenericAttachment]?
        /// The version of the response card format.
        public let version: String?

        public init(contentType: ContentType? = nil, genericAttachments: [GenericAttachment]? = nil, version: String? = nil) {
            self.contentType = contentType
            self.genericAttachments = genericAttachments
            self.version = version
        }

        private enum CodingKeys: String, CodingKey {
            case contentType
            case genericAttachments
            case version
        }
    }

    public struct SentimentResponse: AWSDecodableShape {
        /// The inferred sentiment that Amazon Comprehend has the highest confidence in.
        public let sentimentLabel: String?
        /// The likelihood that the sentiment was correctly inferred.
        public let sentimentScore: String?

        public init(sentimentLabel: String? = nil, sentimentScore: String? = nil) {
            self.sentimentLabel = sentimentLabel
            self.sentimentScore = sentimentScore
        }

        private enum CodingKeys: String, CodingKey {
            case sentimentLabel
            case sentimentScore
        }
    }
}

// MARK: - Errors

/// Error enum for LexRuntimeService
public struct LexRuntimeServiceErrorType: AWSErrorType {
    enum Code: String {
        case badGatewayException = "BadGatewayException"
        case badRequestException = "BadRequestException"
        case conflictException = "ConflictException"
        case dependencyFailedException = "DependencyFailedException"
        case internalFailureException = "InternalFailureException"
        case limitExceededException = "LimitExceededException"
        case loopDetectedException = "LoopDetectedException"
        case notAcceptableException = "NotAcceptableException"
        case notFoundException = "NotFoundException"
        case requestTimeoutException = "RequestTimeoutException"
        case unsupportedMediaTypeException = "UnsupportedMediaTypeException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize LexRuntimeService
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.
    public static var badGatewayException: Self { .init(.badGatewayException) }
    ///  Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes.
    public static var badRequestException: Self { .init(.badRequestException) }
    ///  Two clients are using the same AWS account, Amazon Lex bot, and user ID.
    public static var conflictException: Self { .init(.conflictException) }
    ///  One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,    If Amazon Lex does not have sufficient permissions to call a Lambda function.   If a Lambda function takes longer than 30 seconds to execute.   If a fulfillment Lambda function returns a Delegate dialog action without removing any slot values.
    public static var dependencyFailedException: Self { .init(.dependencyFailedException) }
    /// Internal service error. Retry the call.
    public static var internalFailureException: Self { .init(.internalFailureException) }
    /// Exceeded a limit.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// This exception is not used.
    public static var loopDetectedException: Self { .init(.loopDetectedException) }
    /// The accept header in the request does not have a valid value.
    public static var notAcceptableException: Self { .init(.notAcceptableException) }
    /// The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.
    public static var notFoundException: Self { .init(.notFoundException) }
    /// The input speech is too long.
    public static var requestTimeoutException: Self { .init(.requestTimeoutException) }
    /// The Content-Type header (PostContent API) has an invalid value.
    public static var unsupportedMediaTypeException: Self { .init(.unsupportedMediaTypeException) }
}

extension LexRuntimeServiceErrorType: Equatable {
    public static func == (lhs: LexRuntimeServiceErrorType, rhs: LexRuntimeServiceErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension LexRuntimeServiceErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
